package com.tfswue.qiu.controller;

import com.tfswue.qiu.entity.User;
import com.tfswue.qiu.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/api/users")

@RefreshScope
public class UserController {
    @Autowired
    private UserService userService;

    // 获取nacos配置，测试nacos，远程调用配置文件
// nacos 读取配置
    @Value("${config.info}")
    private String configInfo;
    @GetMapping("/config/info")
    public String getConfigInfo() {
        return "configInfo:" + configInfo;
    }


    @GetMapping("/{id}")
    public User getUserById(@PathVariable("id") Long id) {
        log.error("getUserById");
        return userService.getUserById(id);
    }
}
